package com.example.applicationview.view;

import android.content.Context;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

import androidx.annotation.Nullable;

import com.example.applicationview.R;

/**
 * 测试
 * path.setFillType
 *
 */
public class BaseView extends View {
    protected Paint mPaint;
    // 宽高
    protected int mWidth, mHeight;

    public BaseView(Context context) {
        this(context, null);
    }

    public BaseView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initPaint();
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        mWidth = w;
        mHeight = h;

        Log.e("onDraw", mWidth + " " + mHeight);
    }

    private void initPaint(){
        mPaint = new Paint();
        mPaint.setAntiAlias(true);          //抗锯齿
        mPaint.setColor(getResources().getColor(R.color.active));//画笔颜色
//        mPaint.setStyle(Paint.Style.STROKE);  //画笔风格
        mPaint.setStyle(Paint.Style.FILL);  //画笔风格
        mPaint.setTextSize(30);             //绘制文字大小，单位px
        mPaint.setStrokeWidth(10);           //画笔粗细
    }

}
